package top.infopub.job.quartz.exec;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import top.infopub.job.cap.service.RepaymentScheduleService;
import top.infopub.job.mkt.service.BidOpenResultService;
import top.infopub.job.quartz.exec.base.BaseJob;
import top.infopub.util.DateUtil;
import top.infopub.util.SpringContext;

/**
 * @Description:
 * @Author: Tszzzzzz
 * @Date: 2021/6/7
 */
public class RepayJob extends BaseJob {

    private static RepaymentScheduleService repaymentScheduleService;

    static {
        repaymentScheduleService = SpringContext.getBean(RepaymentScheduleService.class);
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        try {
            String start = DateUtil.currentDateDef();
            log.info("RepayJob开始时间：{}", start);
            repaymentScheduleService.autoGenerateRepay();
            String end = DateUtil.currentDateDef();
            log.info("RepayJob结束时间：{}", end);
            logSucceed("还款计划执行完成，开始时间：" + start + "，结束时间：" + end);
        }
        catch (Exception e) {
            log.error("还款计划执行error", e);
            logFail(e, true);
        }
    }
}
